<html>
<head><meta charset="utf-8"><title>Clippy &lt;3 MIR? · clippy · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/index.html">clippy</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Clippy.20.3C3.20MIR.3F.html">Clippy &lt;3 MIR?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="220616268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Clippy%20%3C3%20MIR%3F/near/220616268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Clippy.20.3C3.20MIR.3F.html#220616268">(Dec 21 2020 at 18:48)</a>:</h4>
<p>I see a lot of bugs that should probably be fixed with MIR (often where a suggestion causes an ownership error), or are tagged with T-MIR, but there is very little existing code in clippy that uses MIR. Why is that? Is there anything preventing me from making contributions with MIR? Also I don't understand the implications of this issue: <a href="https://github.com/rust-lang/rust-clippy/issues/6080">rust-lang/rust-clippy#6080</a>. Is this a blocker for using MIR in clippy?</p>



<a name="220627617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Clippy%20%3C3%20MIR%3F/near/220627617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Clippy.20.3C3.20MIR.3F.html#220627617">(Dec 21 2020 at 20:36)</a>:</h4>
<p>We're trying to avoid MIR lints, because they are hard to maintain, since you need knowledge of how MIR works. So if there is a lint like the redundant_clone lint, which uses many things of MIR, we can't rely on new contributors to fix issues in those lints. Also reviewing fixes to MIR lints takes long.</p>
<p>If there would be a reusable utils functions, that can be used to check borrowing issues in suggestions, that would be great.</p>



<a name="220628032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Clippy%20%3C3%20MIR%3F/near/220628032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Clippy.20.3C3.20MIR.3F.html#220628032">(Dec 21 2020 at 20:40)</a>:</h4>
<p>I see. For a util function then, we should use <code>mir_const</code>, but we can't until 6080 is resolved? Is it okay to use <code>optimized_mir</code> in the meantime?</p>



<a name="220628234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Clippy%20%3C3%20MIR%3F/near/220628234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Clippy.20.3C3.20MIR.3F.html#220628234">(Dec 21 2020 at 20:42)</a>:</h4>
<p>That's where my knowledge ends. I also don't really know what this issue is about, exactly.</p>



<a name="220669618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Clippy%20%3C3%20MIR%3F/near/220669618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Clippy.20.3C3.20MIR.3F.html#220669618">(Dec 22 2020 at 08:49)</a>:</h4>
<p>Thinking about this a bit more: making MIR more accessible for Clippy might be a great project for 2021 (under the "FP reduction" point, maybe). This could be by working together with the MIR working group (if that exists?) or just writing some documentation how to use MIR in Clippy (as a starting point).</p>



<a name="220669788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Clippy%20%3C3%20MIR%3F/near/220669788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Clippy.20.3C3.20MIR.3F.html#220669788">(Dec 22 2020 at 08:51)</a>:</h4>
<p><span aria-label="wave" class="emoji emoji-1f44b" role="img" title="wave">:wave:</span> from <span class="user-group-mention" data-user-group-id="1162">@WG-mir-opt</span></p>



<a name="220669853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Clippy%20%3C3%20MIR%3F/near/220669853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Clippy.20.3C3.20MIR.3F.html#220669853">(Dec 22 2020 at 08:52)</a>:</h4>
<p>(we optimize MIR. both values of it as well as its datastructures)</p>



<a name="220675937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Clippy%20%3C3%20MIR%3F/near/220675937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Clippy.20.3C3.20MIR.3F.html#220675937">(Dec 22 2020 at 10:21)</a>:</h4>
<p>So I think the most reasonable way forward is for me to carry <a href="https://github.com/rust-lang/rust/pull/78407">https://github.com/rust-lang/rust/pull/78407</a> over the finish line (had that planned for the holidays anyway), then introduce a way to ensure that clippy will end up getting the right MIR. Showcase that with the unnecessary clone lint and write documentation explaining all of that</p>



<a name="220707721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Clippy%20%3C3%20MIR%3F/near/220707721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Clippy.20.3C3.20MIR.3F.html#220707721">(Dec 22 2020 at 16:27)</a>:</h4>
<p>One thing other than bug fixes that would be good for MIR is abstract interpretation. For instance linting an always true condition: <code>if a &amp;&amp; b { if b { .. } }</code>.</p>



<a name="220708689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Clippy%20%3C3%20MIR%3F/near/220708689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Clippy.20.3C3.20MIR.3F.html#220708689">(Dec 22 2020 at 16:36)</a>:</h4>
<p>I'd be happy to write documentation for using MIR after getting some experience!</p>



<a name="223924669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Clippy%20%3C3%20MIR%3F/near/223924669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Clippy.20.3C3.20MIR.3F.html#223924669">(Jan 25 2021 at 16:42)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/257328-clippy/topic/Clippy.20.3C3.20MIR.3F/near/220675937">said</a>:</p>
<blockquote>
<p>then introduce a way to ensure that clippy will end up getting the right MIR</p>
</blockquote>
<p>So now we need to do this part?</p>



<a name="224013331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Clippy%20%3C3%20MIR%3F/near/224013331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Clippy.20.3C3.20MIR.3F.html#224013331">(Jan 26 2021 at 09:16)</a>:</h4>
<p>yea... so... clippy can now use <code>mir_for_ctfe</code>, which is badly named for this task, but simply the MIR before optimizations</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>